<?php

class actContacts extends action
{
	function translate($a)
	{
		$t = '';
		
		foreach($a AS $contact)
		{
			$t .= $contact['pUser'] . "," . $contact['status'] . "," . $contact['status_de'] . "," . $contact['nickname'] . "\n";
			
		} // end foreach
		
		return $t;
		
	} // end function
	
	function execute($m)
	{
		// Check if the key is correct.
		$this->checkKey($this->getInput('k')) or $this->doAjaxError();
		
		// Get contacts model
		$cM = $m->getModel('contacts');
		
		// Get all the contacts translated for transfering
		$c = $this->translate($cM->getAll($m, (($this->getInput('i') == 1) ? true : false)));
		
		// Set new key 
		$this->setNewKey();
		
		// Add the contacts output
		$this->addOutput($c);
		
		// Finish!
		$this->finish();
		
	} // end function
	
} // end class

$_ = 'actContacts';

?>